package com.pine.sunshineelder.eldernurselevel.web.handler;


import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.pine.sunshineelder.common.dto.JSONResponse;
import com.pine.sunshineelder.common.entity.ElderNursedEntity;
import com.pine.sunshineelder.eldernurselevel.ao.NursedAddAo;
import com.pine.sunshineelder.eldernurselevel.ao.NursedModAo;
import com.pine.sunshineelder.eldernurselevel.service.ElderNursedService;

@RestController
@RequestMapping("/api")
public class ElderNursedHandler {
	@Autowired
	ElderNursedService nursedService;

	@PostMapping("/nadd")
	public JSONResponse increaseRecord(NursedAddAo ao) throws Exception {
		return JSONResponse.ok(nursedService.addNursed(ao));
	}
	@PostMapping("/ndel")
	public JSONResponse deleteRecord(String id) throws Exception{
		nursedService.deleteNursed(id);
		return JSONResponse.ok();
		
	}
	@PutMapping("/nursed/{id}")
	public JSONResponse modefiNursed(@PathVariable String id,NursedModAo ao) throws Exception{
		Map<String, String> map=new HashMap<String, String>();
		map.put("endTime", ao.getEndTime());
		map.put("changeReason",ao.getChangeReason());
		ElderNursedEntity modefiNursed= nursedService.modeifyNused(id, map);
		return JSONResponse.ok(modefiNursed);
		
	}

}
